// 定时器版本
function debounce(fn, delay) {
	let timeout = null
	return function(...argus) {
		clearTimeout(timeout)
		timeout = setTimeout(() => {
			fn.apply(this, argus)
		}, delay)
	}
}

// 定时器版本节流
function throttle(func, delay) {
    var timer = null;
    return function () {
        if (!timer) {
            func.apply(this, arguments);
            timer = setTimeout(() => {
                timer = null;
            }, delay);
        } else {
            console.log("上一个定时器尚未完成");
        }
    }
}

// 时间戳版本节流
function throttle(func, delay) {
	let last = 0
	return function(...argus) {
		const now = new Date()
		if (now >= last + delay) {
			func.apply(this, argus)
			last = now
		} else {
			console.log('距离上次调用的时间不满足')
		}	
	}
}